{include file="public/header" /}
<body>
<div class="header">
    <span class="layui-icon layui-icon-left" onclick="load_href('{:url(\'user/index\')}',2)"></span> 我的释放订单
</div>
<ul class="my-order-nav bgc">
    <li data-type="" class="{if !$Request.param.type}active{/if}">全部</li>
    <li data-type="1" class="{if $Request.param.type == 1}active{/if}">释放中</li>
    <li data-type="2" class="{if $Request.param.type == 2}active{/if}">释放完成</li>
</ul>
<ul class="my-order-list tpl_list"></ul>
<script id="template" type="text/html">
    {{# for(var i=0;i < d.data.length ;i++){ }}
    <li>
        <p style="color: #000">订单号：{{d.data[i].sn}}</p>
        <p>订单金额：{{d.data[i].real_amount}}</p>
        <p>封顶金额：{{d.data[i].green}}</p>
        <p>已释放：{{d.data[i].release}}</p>
        <p>创建时间：{{d.data[i].create_time}}</p>
        {{# if(d.data[i].is_release == '1'){ }}
        <p style="color: red">已封顶</p>
        {{# }else { }}
        <p style="color: #59B573">释放中</p>
        {{# } }}
        <p></p>
    </li>

    {{# } }}
</script>
</body>
{include file="public/footer"/}
<script>
    $(function () {
        getFlow('{$Request.param.type?:""}', "{:url('order/getRelease')}");
        $('.my-order-nav li').click(function () {
            $(".tpl_list").empty();
            getFlow($(this).attr('data-type'), "{:url('order/getRelease')}");
            $(this).addClass('active').siblings().removeClass('active')
        });
        $('.tpl_list').on('click', '.clearOrder', function () {
            const id = $(this).attr('data-id');
            edit('clear', id, '确认要取消订单吗？')
        }).on('click', '.receipt', function () {
            const id = $(this).attr('data-id');
            edit('receipt', id, '是否确认收货？')
        });
        function edit(type, id, msg) {
            layer.confirm(msg, {title: '请确认'}, function () {
                common.load()
                $.ajax({
                    type: 'POST',
                    url: '{:url("order/edit")}',
                    data: {type: type, id: id},
                    dataType: "json",
                    success: function (data) {
                        layer.closeAll;
                        layer.msg(data.msg);
                        if (data.code == 1) {
                            $(".tpl_list").empty();
                            getFlow($(".active").attr('data-type'), "{:url('order/getRelease')}");
                        }
                    }
                });
            });
        }
    })
</script>
</html>